﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ServerMonitor
{
    public partial class WarningSet : Form
    {
        Form1 f;
        public WarningSet(Form1 form)
        {
            f = form;
            InitializeComponent(); 

            tbCount.Value = f.setting.Count;
            tbCpu.Value = f.setting.CpuAlarm;
            tbDisk.Value = f.setting.DiskAlarm;
            tbInterval.Value = f.setting.Interval;
            tbMemory.Value = f.setting.MemoryAlarm;
            tbPhoneNumbers.Text = f.setting.PhoneNumbers;  
            tbUpKbs.Value = f.setting.UpKbs;
            tbDownKbs.Value = f.setting.DownKbs;
            tbConnectCount.Value = f.setting.ConnectCount;
            tbDBs.Text = f.setting.DbNames;
            tbConStr.Text = f.setting.ConStr;
            tbIps.Text = f.setting.Ips;
            tbOpenId.Text = f.setting.OpenId;


        }

        private void btSave_Click(object sender, EventArgs e)
        {
            Common.LogHelper.Log("修改配置：报警次数" + f.setting.Count + "->" + tbCount.Value);
            f.setting.Count = (int)tbCount.Value;


            Common.LogHelper.Log("修改配置：报警次数" + f.setting.Count + "->" + tbCount.Value);
            f.setting.OpenId = tbOpenId.Text;




            Common.LogHelper.Log("修改配置：CPU报警值" + f.setting.CpuAlarm+ "->" + tbCpu.Value);
            f.setting.CpuAlarm = (int)tbCpu.Value;

            Common.LogHelper.Log("修改配置：磁盘报警值" + f.setting.DiskAlarm+ "->" + tbDisk.Value);
            f.setting.DiskAlarm = (int)tbDisk.Value;

            Common.LogHelper.Log("修改配置：报警时间间隔" + f.setting.Interval+ "->" + tbInterval.Value);
            f.setting.Interval = (int)tbInterval.Value;

            Common.LogHelper.Log("修改配置：内存报警值" + f.setting.MemoryAlarm+ "->" + tbMemory.Value);
            f.setting.MemoryAlarm = (int)tbMemory.Value;

            Common.LogHelper.Log("修改配置：报警手机号" + f.setting.PhoneNumbers + "->" + tbPhoneNumbers.Text);
            f.setting.PhoneNumbers = tbPhoneNumbers.Text;

            Common.LogHelper.Log("修改配置：上行带宽" + f.setting.UpKbs+ "->" + tbUpKbs.Value);
            f.setting.UpKbs = (int)tbUpKbs.Value;

            Common.LogHelper.Log("修改配置：下行带宽" + f.setting.DownKbs + "->" + tbDownKbs.Value);
            f.setting.DownKbs = (int)tbDownKbs.Value;

            Common.LogHelper.Log("修改配置：数据库连接数" + f.setting.ConnectCount+ "->" + tbConnectCount.Value);
            f.setting.ConnectCount = (int)tbConnectCount.Value;

            Common.LogHelper.Log("修改配置：监控数据库" + f.setting.DbNames+ "->" + tbDBs.Text);
            f.setting.DbNames = tbDBs.Text;

            Common.LogHelper.Log("修改配置：连接字符串" + f.setting.ConStr + "->" + tbConStr.Text);
            f.setting.ConStr = tbConStr.Text;

            Common.LogHelper.Log("修改配置：监控服务器Ip" + f.setting.Ips+ "->" + tbIps.Text);
            f.setting.Ips= tbIps.Text;

            Common.LogHelper.Log("修改配置：报警次数->" + f.setting.Count);

            this.Close();
        }
 
    }
}
